<template>
    <div class="films-box">
        <div class="list-name">
            <!-- <span>{{$route.query.typeName}}</span> -->
            <span>{{reWriteTypeName}}</span>
        </div>
        <!-- <film-list class="content-list" :list="films"></film-list> -->
        <FilmList class="content-list" :filmList="filmList"></FilmList>
    </div>
</template>
<script>
import FilmList from "../components/filmList";
export default {
    components: {
        FilmList
    },
    props:{
    },
    data(){
        return{
            filmList:[]
        }
    },
    computed:{
        reWriteTypeName(){
            return this.$route.params.typeName?this.$route.params.typeName.replace("/\.html$/",""):"全网查询";
        }
    },
    methods:{
        loadFilmsByTypeId(){
            let params={
                size:12
            };
            if(this.$route.params.typeId){
                params.typeId=this.$route.params.typeId;
            }else{
                params.seach=this.$route.params.seach;
            }
            // this.$api.loadFilms({
            //     // typeId:this.$route.query.typeId,//get参数请求(query)
            //     typeId:this.$route.params.typeId,//rest参数请求(params)
            //     size:11
            // }).then(({resultState,result})=>{
            this.$api.loadFilms(params).then(({resultState,result})=>{
                if(!resultState){
                    return Promise.reject("网络错误");
                    // throw new Error("错误");
                }
                this.filmList=result;
            }).catch((error)=>{
                // console.log(error);
                this.$error(error);
            });
        }
    },
    mounted(){
        this.loadFilmsByTypeId();
    }
};
</script>
<style lang="less" scoped>
// 分类页样式
.films-box {
    position: absolute;
    top: 0rem;
    bottom: 0rem;
    left: 0rem;
    right: 0rem;
    overflow-y: auto;
}
.content-list {
    display: flex;
    flex-flow: row wrap;
    justify-content: left;
    width: 100%;
    font-size: 0rem;
    > * {
        margin-top: 0.2rem;
    }
}
</style>